package com.hongyu.smart.village.manager;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.hongyu.smart.village.R;


public class DialogManager {
    /**
     * 显示加载对话框
     * @param context
     */
    public static ProgressDialog getLoadingDialog(Context context) {
        ProgressDialog dialog = new ProgressDialog(context);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setMessage(context.getString(R.string.loading_dialog_message));
        dialog.setIndeterminate(false);
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);
        return dialog;
    }
    public static ProgressDialog getLoadDialog(Context context) {
        ProgressDialog dialog = new ProgressDialog(context);
        dialog.setContentView(R.layout.dialog_loading_layout);
        return dialog;
    }
    /**
     * 显示列表对话框
     * @param context
     * @param title
     */
    public static AlertDialog showListAlertDialog(Context context, String title, String[]items, DialogInterface.OnClickListener clickListener) {
        AlertDialog dlg=new AlertDialog.Builder(context)
                .setIcon(R.mipmap.no_image)
                .setTitle(title)
                .setItems(items, clickListener).show();

        return dlg;
    }

    public static AlertDialog getCheckDialog(Context context, String title, String msg, DialogInterface.OnClickListener postiveClickListener, DialogInterface.OnClickListener negativeClickListener) {
        AlertDialog dlg = new AlertDialog.Builder(context)
                .setIcon(android.R.drawable.ic_dialog_info)
                .setTitle(title)
                .setMessage(msg)
                .setCancelable(true)
                .setPositiveButton("确定", postiveClickListener)
                .setNegativeButton("取消", negativeClickListener).create();

        return dlg;


    }
}
